package com.liruo.springframework.core.aop.springinterceptor;

import org.springframework.aop.framework.autoproxy.AbstractBeanFactoryAwareAdvisingPostProcessor;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.aop.support.NameMatchMethodPointcut;
import org.springframework.aop.support.RootClassFilter;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;


@Component
public class SimpleTraceMethodPostProcessor extends
    AbstractBeanFactoryAwareAdvisingPostProcessor implements
    InitializingBean {

  @Override
  public void afterPropertiesSet() throws Exception {
    NameMatchMethodPointcut pointcut = new NameMatchMethodPointcut();
    pointcut.setClassFilter(new RootClassFilter(CommonTarget.class));
    pointcut.addMethodName("common");
    this.advisor =  new DefaultPointcutAdvisor(
        pointcut,
        new SimpleTraceMethodInterceptor(SimpleTraceMethodPostProcessor.class.getSimpleName())
    );
  }
}
